{include file="public/head"}
    <body>
    <div class="x-body" >

    <!--     <div class="lotus-nav layui-row ">
              <p style="float: left;margin-top: 3px;"><span class="layui-badge-dot"></span>温馨提示:数据无价,请谨慎操作</p>
            <span class="x-right" >数据库表数量:
               
                 <button onclick="javascript:location.reload()" class="layui-btn-default">
                    <i class="icon iconfont">&#xe6aa;</i>
                </button>
            </span>
        </div> -->

    <table class="layui-table">
        <thead>
          <tr>
            <th>备份文件</th>
            <th>文件大小</th>
            <th width="18%">操作</th>
        </thead>
        <tbody>
         {empty name="list"}
                            <tr>
                                <td class="no-data" align="center" axis="col0" colspan="50">
                                    <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                                </td>
                            </tr>
                        {else/}
                            {foreach name="list" item="vo" key="k" }
                            <tr >
                                <td >
                                    <div style="padding-left: 10px;">{$vo.filename}</div>
                                </td>
                                <td>{$vo.size}</td>
                                <td>
                                    <button onclick="javascript:layer.alert('演示数据保护')" class="layui-btn layui-btn-xs">下载</button>
                                    <!-- <button class="layui-btn layui-btn-normal layui-btn-xs">恢复</button> -->
                                    <button class="layui-btn layui-btn-danger layui-btn-xs" onclick="delSql('{$vo.filename}')">删除</button>
                                </td>
                            </tr>
                            {/foreach}
                        {/empty}
        </tbody>
      </table>
	    
    </div>
</body>
{include file="public/foot"}
<script type="text/javascript">
    $(function(){



       $(".many-tables").click(function(event) {
         //询问框
        layer.confirm('是否确认备份？', {
          btn: ['确定','取消'] //按钮
        }, function(){
             var data = tableCheck.getData();
        backup(data);
        });

       
       });
    })
    //备份数据库
    function backup(tables){
        layer.load();
        $.ajax({
            url: 'backup',
            type: 'post',
            dataType: 'json',
            data: {tables: tables},
        })
        .done(function(data) {
            layer.closeAll('loading');
            if(data.msg!==0){
                layer.alert(data.msg);
            }else{
                layer.msg('备份失败');
            }
        })
        
    }
    function delSql(filename){
         layer.confirm('是否确认备份？', {
          btn: ['确定','取消'] //按钮
        }, function(){
              $.ajax({
            url: 'delSql',
            type: 'post',
            dataType: 'json',
            data: {filename: filename},
            })
            .done(function(data) {
                 if(data.code!==0){
                    layer.msg(data.msg,{time:1000},function(){
                        location.reload();
                    });
                 }else{
                    layer.msg(data.msg);
                 }
            })

        });


      
        
    }
</script>
